Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Whatsapp integration #2335

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open

Whatsapp integration #2335

wants to merge 20 commits into from

Conversation

Ansub
Copy link
Member

@Ansub Ansub commented Mar 8, 2025

Description

  • Summary of changes: Describe the key changes in this PR and their purpose.
  • Related issues: Mention if this PR fixes or is connected to any issues.
  • Motivation and context: Explain the reason for the changes and the problem they solve.
  • Environment or dependencies: Specify any changes in dependencies or environment configurations required for this update.
  • Impact on metrics: (If applicable) Describe changes in any metrics or performance benchmarks.

Fixes # (issue)


Type of change

Please check the options that are relevant:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Model update (Addition or modification of models)
  • Other (please describe):

Checklist

  • Adherence to standards: Code complies with Agno’s style guidelines and best practices.
  • Formatting and validation: You have run ./scripts/format.sh and ./scripts/validate.sh to ensure code is formatted and linted.
  • Self-review completed: A thorough review has been performed by the contributor(s).
  • Documentation: Docstrings and comments have been added or updated for any complex logic.
  • Examples and guides: Relevant cookbook examples have been included or updated (if applicable).
  • Tested in a clean environment: Changes have been tested in a clean environment to confirm expected behavior.
  • Tests (optional): Tests have been added or updated to cover any new or changed functionality.

Additional Notes

Include any deployment notes, performance implications, security considerations, or other relevant information (e.g., screenshots or logs if applicable).

@Ansub Ansub requested a review from a team as a code owner March 8, 2025 19:17
Comment on lines 55 to 56
self.register(self.send_text_message_sync)
self.register(self.send_template_message_sync)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about async? Maybe have a async_mode:bool attribute at the top? We don't really build async endpoints yet, but that could be a good pattern

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

response.raise_for_status()
return response.json()

def send_text_message_sync(self, recipient: Optional[str] = None, text: str = "", preview_url: bool = False) -> str:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would make text the first attribute

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Ansub added 9 commits March 10, 2025 19:23
- Clarify ngrok setup instructions as development testing only
- Add missing environment variable for WhatsApp recipient phone number
- Regenerate requirements.txt with updated dependencies
- Minor formatting and clarity improvements in documentation
…ok domain details

- Change environment configuration from `.env` to `.envrc` for better environment variable management
- Add instructions for using a static ngrok domain
- Remove duplicate `WHATSAPP_WEBHOOK_URL` environment variable
- Improve documentation clarity for webhook and ngrok setup
- Remove verbose logging in webhook verification and server startup
- Remove dotenv loading from WhatsApp tools
- Minor formatting improvements in README and code
- Correct duplicate environment variable checks for access token, phone number ID, recipient, and version
- Ensure consistent fallback to specific WhatsApp-prefixed environment variables
- Rename `whatsapp_chat_agent.py` to `app.py`
- Update README to reflect the new script name in startup instructions
- Swap order of `recipient` and `text` parameters for better readability
- Update method docstring to match new parameter order
- Enhance debugging by logging request and response details
- Log URL, headers, request data, status code, response headers, and response body
- Use json.dumps for better readability of logged data
- Introduce `async_mode` parameter to enable async message sending methods
- Implement `send_text_message_async` and `send_template_message_async` methods
- Update toolkit initialization to conditionally register sync or async methods
- Enhance configuration logging to include async mode status
name="whatsapp",
tools=[WhatsAppTools()],
)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a simple chat example as well?

dirkbrnd and others added 5 commits March 11, 2025 15:58
- Replaced YFinanceTools with DuckDuckGoTools for improved search capabilities.
- Updated agent description to reflect the new functionality and interaction style.
- Removed duplicate webhook URL export from README for clarity.
- Revised README to reflect the new AI agent functionality and improved setup instructions.
- Added detailed steps for obtaining WhatsApp credentials and configuring the environment.
- Enhanced error handling and troubleshooting sections for better user guidance.
- Updated `whatsapp_tools.py` to include links for easier navigation and clarified environment variable setup.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants